import request from '@/utils/request';

/**
 *  获取岗位列表
 * @param {*} data
 * @returns
 */
export const getAllPositionsAPI = ({ positionName, positionStatus, page, limit }) => {
  console.log({ positionName, positionStatus, page, limit });
  return request({
    url: '/personnelManagement/positions/getAllPositions',
    method: 'POST',
    data: {
      positionName,
      positionStatus,
      page,
      limit,
    },
  });
};

/**
 *  删除岗位列表
 * @param {*} data
 * @returns
 */
export const deletePositionsAPI = (positionId) => {
  return request({
    url: `/personnelManagement/positions/deletePositions/${positionId}`,
    method: 'POST',
  });
};

/**
 *  通过岗位id查询员工
 * @param {*} data
 * @returns
 */
export const getEmployeeByPositionIdAPI = ({ positionId, name, page, limit }) => {
  return request({
    url: '/personnelManagement/positions/getEmployeeByPositionId',
    method: 'POST',
    data: {
      positionId,
      name,
      page,
      limit,
    },
  });
};

/**
 *  删除岗位人员列表
 * @param {*} data
 * @returns
 */
export const delemployeesAPI = (employeeId) => {
  return request({
    url: `/personnelManagement/employees/employees/${employeeId}`,
    method: 'POST',
  });
};

/**
 *  获取部门列表
 * @param {*} data
 * @returns
 */
export const getDepartmentAPI = () => {
  return request({
    url: '/personnelManagement/departments/getDepartmentRelationshipMap',
    method: 'POST',
  });
};

/**
 *  添加岗位
 * @param {*} data
 * @returns
 */
export const addPositionsAPI = ({ positionName, departmentId, salary, positionStatus }) => {
  return request({
    url: '/personnelManagement/positions/addPositions',
    method: 'POST',
    data: {
      positionName,
      departmentId,
      salary,
      positionStatus,
    },
  });
};

/**
 *  修改岗位信息
 * @param {*} data
 * @returns
 */
export const updatePositionAPI = ({
  positionId,
  positionName,
  departmentId,
  salary,
  positionStatus,
}) => {
  return request({
    url: '/personnelManagement/positions/updatePosition1',
    method: 'POST',
    data: {
      positionId,
      positionName,
      departmentId,
      salary,
      positionStatus,
    },
  });
};
